package com.martin.lib_base.ui.screen

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.martin.lib_base.ui.theme.ColorGradient
import com.martin.lib_base.ui.theme.ColorPrimary
import com.martin.lib_base.ui.theme.ColorSecondary
import com.martin.lib_base.ui.theme.Shapes

/**
 * @author：孟凡华
 * @date：2023/7/5
 * @desc：
 */

/**
 * 通用按钮
 */
@Composable
fun CommonButton(
    text: String = "确定",
    paddingHorizontal: Dp = 0.dp,
    paddingTop: Dp = 0.dp,
    paddingBottom: Dp = 0.dp,
    height: Dp = 44.dp,
    shape: Shape = CircleShape,
    color: Color = Color.White,
    background: Modifier = Modifier
        .background(
            brush = Brush.horizontalGradient(
                colors = ColorGradient,
            ),
            shape = shape
        ),
    onClick: () -> Unit,
) {
    Center(
        modifier = Modifier
            .padding(horizontal = paddingHorizontal)
            .padding(top = paddingTop, bottom = paddingBottom)
            .fillMaxWidth()
            .height(height)
            .then(background)
            .clickable { onClick() }
    ) {
        Text(
            text = text,
            fontSize = 16.sp,
            color = color,
            fontWeight = FontWeight.Medium
        )
    }
}